import React, { useState } from 'react'
import Button from './Button';
import Image from './Image';

export default function SwitchImage() {
  //声明状态
  let [src, setSrc] = useState('http://api.xiaohigh.com/image/random');

  //声明事件回调
  let change = () => {
    setSrc('http://api.xiaohigh.com/image/random?t='+Date.now());// 添加 url 的query参数
  }

  return (
    <div>
      <Button onClick={change} />
      <hr />
      <Image path={src} />
    </div>
  )
}
